/* Author: SRIRAM CHAUDHURY (sriram_c@students.iiit.ac.in) */
#include <string.h>
#include <search.h>
#define VERY_LARGE 100

adj_handle_yA_huA(result,match_word)
char match_word[VERY_LARGE],result[VERY_LARGE];
{
	char *mark,*match_iyI,root_iyI[VERY_LARGE],tmp_result[VERY_LARGE];
	strcpy(tmp_result,"");
	mark = strchr(match_word,'~');
	int mark_posn = strlen(match_word)-strlen(mark);
	strncpy(tmp_result,match_word,mark_posn);
	char ch1 = match_word[(strlen(match_word)-strlen(mark)-1)];
	if ((ch1 == 'A') && (!strcmp(mark,"~huA"))){
		*(tmp_result + mark_posn) = '\0';
		if(!strcmp(tmp_result,"pExA")) {
			strcat(tmp_result,"_huI");
			strcpy(result,tmp_result);
		}
		else	{
				*(tmp_result + mark_posn-1) = '\0';
				strcat(tmp_result,"I");
                                if ((match_iyI = strstr(tmp_result,"iyI")) != NULL){
//				match_iyI = strstr(tmp_result,"iyI");
				int mark_before_iyI= strlen(tmp_result)-strlen(match_iyI);
				if (!strcmp(match_iyI,"iyI\0")){
					strncpy(root_iyI,tmp_result,mark_before_iyI);
					*(root_iyI + mark_before_iyI) = '\0';
					strcat(root_iyI,"I_huI");
					strcpy(result,root_iyI);
				}
			}
				else {	
					strcat(tmp_result,"_huI");
					strcpy(result,tmp_result);
				}
			}
	}
}

/*
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <search.h>
#include "adj_handle_yA_huA.c"

main(argc,argv)
int argc;
char *argv[];
{
char str[100],ch,result[VERY_LARGE];

scanf("%s",str);
while(strcmp(str,"NULL")) {
	adj_handle_yA_huA(result,str);
	printf("%s\t%s\n",str,result);
	scanf("%s",str);
	}
}
 */
